package tjs.study.notes.dotest.jdk;

import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * Created by Nicky.Tang on 2022/4/6 11:44 上午
 *
 * @since 02.12.10
 */
public class StreamTest {

    public void testTomap() {
        List<UserStream> userStreamList = new ArrayList<>();
        LinkedHashMap<String, UserStream> honeyResourcesMap = userStreamList.stream().collect(Collectors.toMap(UserStream::getId, Function.identity(), (i1, i2) -> i1, LinkedHashMap::new));
    }

    public void testPut() {
        Map<String, List<UserStream>> userStreamMap = new HashMap<>();
        userStreamMap.computeIfAbsent("aa", k -> new ArrayList<>()).add(new UserStream("aa"));
    }

    private static class UserStream {
        private String id;

        public UserStream(String id) {
            this.id = id;
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }
    }
}
